*****Manifesto coding for the four countries

*Download Manifesto project dataset from https://manifestoproject.wzb.eu/datasets. The analyses in the paper are estimated using dataset version 2024a

cd "C:\Users\\`=c(username)'\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Outputs\Final figures" // replace with your directory

***Denmark

use  "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\MPDataset_MPDS2024a_stata14.dta" , clear // replace with your directory

keep if country==13
gen year=floor(date/100)
drop if year<1971

recode party (13220 13320=1) (13110 13210 13229 13230 =2) (13001 13420 13620=3) (13720 13730 13951=4) (13221 13330 13410 13520 13952=.), gen(party4)

factor per401 per402 per407 per410 per414 per505 per507 per702 per403 per404 per405 per406 per412 per413 per409 per415 per504 per506 per503 per701, fa(1) blanks(.3)
factor per401 per402 per414 per505 per413 per503 per504 per701, fa(1) blanks(.3)
predict ecoposdk

gen ecoposdk2 = ((per401 +per402 +per407 +per410 +per414 +per505 +per507 +per702) - (per403 +per404 +per405 +per406 +per412 +per413 +per409 +per415 +per504 +per506 +per503 +per701))/100

factor per305 per601 per603 per605 per606 per608 per201 per202 per416 per501 per502 per602 per604 per607 per705 per706, fa(1) bl(.3)
factor per305 per601 per605 per608 per202, fa(1) bl(.3)
predict autlibdk

gen autlibdk2 = ((per305 +per601 +per603 +per605 +per606 +per608) - (per201 +per202 +per416 +per501 +per502 +per602 +per604 +per607 +per705 +per706))/100

preserve
collapse (mean) ecoposdk autlibdk ecoposdk2 autlibdk2, by(party year)
collapse (sd) ecoposdk autlibdk ecoposdk2 autlibdk2, by(year)
save "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\DNES\DKmanifest.dta", replace // replace with your directory
restore

gen ecoposdks=ecoposdk if party==13320

preserve
collapse (mean) ecoposdks, by(year)
merge 1:1 year using "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\DNES\DKmanifest.dta" // replace with your directory
drop _merge
save "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\DNES\DKmanifest.dta", replace // replace with your directory
restore

gen ecoposdkp4=ecoposdk
gen autlibdkp4=autlibdk

preserve
collapse (mean) ecoposdkp4 autlibdkp4, by(party4 year)
collapse (sd) ecoposdkp4 autlibdkp4, by(year)
merge 1:1 year using "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\DNES\DKmanifest.dta" // replace with your directory
drop _merge
twoway line ecoposdk autlibdk year, scheme(s1mono) title(Denmark) xtitle("") xlab(1971 1973 1975 1977 1979 1981 1984 1987 1988 1990 1994 1998 2001 2005 2007 2011 2015 2019, angle(45)) lpattern(dash solid) lcolor(black black) legend(order(1 "Economic polarization" 2 "Social polarization")) // saving(manifestdk, replace)
save "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\DNES\DKmanifest.dta", replace // replace with your directory
restore

***Norway

use  "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\MPDataset_MPDS2024a_stata14.dta" , clear // replace with your directory

keep if country==12
gen year=floor(date/100)
drop if year<1977

recode party (12220 12230 12320 =1) (12221 12110=2) (12420 12620=3) (12951=4) , gen(party4)

factor per401 per402 per407 per410 per414 per505 per507 per702 per403 per404 per405 per406 per412 per413 per409 per415 per504 per506 per503 per701, fa(1) blanks(.3)
factor per401 per402 per405 per406 per407 per413 per414 per504 per505 per507 per503 per701 per702, fa(1) blanks(.3)
predict ecoposno

gen ecoposno2 = ((per401 +per402 +per407 +per410 +per414 +per505 +per507 +per702) - (per403 +per404 +per405 +per406 +per412 +per413 +per409 +per415 +per504 +per506 +per503 +per701))/100

factor per305 per601 per603 per605 per606 per608 per201 per202 per416 per501 per502 per602 per604 per607 per705 per706, fa(1)
factor per305 per601 per605 per606 per608 per501 per502 per607 per705 per706, fa(1) bl(.3)
factor per601 per605 per606 per608 per501 per502 per705 per706, fa(1)
predict autlibno1
gen autlibno=autlibno1*-1

gen autlibno2 = ((per305 +per601 +per603 +per605 +per606 +per608) - (per201 +per202 +per416 +per501 +per502 +per602 +per604 +per607 +per705 +per706))/100

preserve
collapse (mean) ecoposno autlibno ecoposno2 autlibno2, by(party year)
collapse (sd) ecoposno autlibno ecoposno2 autlibno2, by(year)
save "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\NNES\NOmanifest.dta", replace // replace with your directory
restore

gen ecoposnoa=ecoposno if party==12320

preserve
collapse (mean) ecoposnoa , by(year)
merge 1:1 year using "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\NNES\NOmanifest.dta" // replace with your directory
drop _merge
save "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\NNES\NOmanifest.dta", replace // replace with your directory
restore

gen ecoposnop4=ecoposno
gen autlibnop4=autlibno

preserve
collapse (mean) ecoposnop4 autlibnop4, by(party4 year)
collapse (sd) ecoposnop4 autlibnop4, by(year)
merge 1:1 year using "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\NNES\NOmanifest.dta" // replace with your directory
drop _merge
twoway line ecoposno autlibno year, scheme(s1mono) title(Norway) xtitle("") xlab(1977 1981 1985 1989 1993 1997 2001 2005 2009 2013 2017, angle(45)) lpattern(dash solid) lcolor(black black) legend(order(1 "Economic polarization" 2 "Social polarization")) // saving(manifestno, replace)
save "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\NNES\NOmanifest.dta", replace // replace with your directory
restore

***Britain

use  "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\MPDataset_MPDS2024a_stata14.dta" , clear // replace with your directory

keep if country==51
gen year=floor(date/100)
replace year=1975 if date==197410
drop if year<1970

factor per401 per402 per407 per410 per414 per505 per507 per702 per403 per404 per405 per406 per412 per413 per409 per415 per504 per506 per503 per701, fa(1) blanks(.3)
factor per401 per402 per403 per413 per414 per504 per503 per701 per702, fa(1) blanks(.3)
predict ecoposuk1
gen ecoposuk=ecoposuk1*-1

gen ecoposuk2 = ((per401 +per402 +per407 +per410 +per414 +per505 +per507 +per702) - (per403 +per404 +per405 +per406 +per412 +per413 +per409 +per415 +per504 +per506 +per503 +per701))/100

factor per305 per601 per603 per605 per606 per608 per201 per202 per416 per501 per502 per602 per604 per607 per705 per706, fa(1)
factor per305 per601 per603 per605 per608 per201 per202 per416 per501 per602 per604 per607 , fa(1) bl(.3)
factor per305 per603 per605 per201 per202 per416 per501 per602 per604 , fa(1)
predict autlibuk1
gen autlibuk=autlibuk1*-1

gen autlibuk2 = ((per305 +per601 +per603 +per605 +per606 +per608) - (per201 +per202 +per416 +per501 +per502 +per602 +per604 +per607 +per705 +per706))/100

gen ecoposukl=ecoposuk if party==51320
gen ecoposukc=ecoposuk if party==51620
gen autlibukl=autlibuk if party==51320
gen autlibukc=autlibuk if party==51620

gen ecoposukl2=ecoposuk2 if party==51320
gen ecoposukc2=ecoposuk2 if party==51620
gen autlibukl2=autlibuk2 if party==51320
gen autlibukc2=autlibuk2 if party==51620

preserve
collapse (mean) ecoposukl ecoposukc autlibukl autlibukc ecoposukl2 ecoposukc2 autlibukl2 autlibukc2, by(year)
gen ecoposuk=ecoposukc-ecoposukl
gen autlibuk=autlibukc-autlibukl
gen ecoposuk2=ecoposukc2-ecoposukl2
gen autlibuk2=autlibukc2-autlibukl2
twoway line ecoposuk autlibuk year, scheme(s1mono) title(Britain) xtitle("") xlab(1970 1974 1975 1979 1983 1987 1992 1997 2001 2005 2010 2015 2017 2019, angle(45)) lpattern(dash solid) lcolor(black black) legend(order(1 "Economic polarization" 2 "Social polarization")) // saving(manifestuk, replace)
save "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\BES\UKmanifest.dta", replace // replace with your directory
restore

***USA

use  "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\MPDataset_MPDS2024a_stata14.dta" , clear // replace with your directory

keep if country==61
gen year=floor(date/100)
drop if year<1956

factor per401 per402 per407 per410 per414 per505 per507 per702 per403 per404 per405 per406 per412 per413 per409 per415 per504 per506 per503 per701, fa(1)
factor per401 per402 per407 per410 per414 per505 per507 per702 per403 per404 per405 per412 per413 per409 per504 per506 per503 per701, fa(1) bl(.3)
factor per401 per403 per412 per413 per414 per409 per504 per505 per506 per507 per503 per702, fa(1) blanks(.3)
predict ecoposus1
gen ecoposus=ecoposus1*-1

gen ecoposus2 = ((per401 +per402 +per407 +per410 +per414 +per505 +per507 +per702) - (per403 +per404 +per405 +per406 +per412 +per413 +per409 +per415 +per504 +per506 +per503 +per701))/100

factor per401 per402 per407 per410 per414 per505 per507 per702 per403 per404 per405 per406 per412 per413 per409 per415 per504 per506 per503 per701 if year>2010, fa(1) blanks(.3)
factor per401 per402 per410 per414 per505 per507 per702 per403 per404 per412 per413 per409 per415 per504 per506 per503 per701, fa(1) blanks(.3)
predict ecoposus31
gen ecoposus3=ecoposus31*-1

factor per305 per601 per603 per605 per606 per608 per201 per202 per416 per501 per502 per602 per604 per607 per705 per706, fa(1)
factor per305 per601 per603 per608 per501 per502 per705 per706, fa(1) bl(.3)
predict autlibus

gen autlibus2 = ((per305 +per601 +per603 +per605 +per606 +per608) - (per201 +per202 +per416 +per501 +per502 +per602 +per604 +per607 +per705 +per706))/100

factor per305 per601 per603 per605 per606 per608 per201 per202 per416 per501 per502 per602 per604 per607 per705 per706 if year>1990, fa(1) bl(.3)
*factor per601 per603 per605 per606 per608 per201 per202 per416 per501 per502 per602 per604 per607 per705, fa(1)
factor per305 per605 per201 per202 per416 per602 per604 per607, fa(1) 
predict autlibus31
gen autlibus3=autlibus31*-1

gen ecoposusd=ecoposus if party==61320
gen ecoposusr=ecoposus if party==61620
gen autlibusd=autlibus if party==61320
gen autlibusr=autlibus if party==61620

gen ecoposusd2=ecoposus2 if party==61320
gen ecoposusr2=ecoposus2 if party==61620
gen autlibusd2=autlibus2 if party==61320
gen autlibusr2=autlibus2 if party==61620

gen ecoposusd3=ecoposus3 if party==61320
gen ecoposusr3=ecoposus3 if party==61620
gen autlibusd3=autlibus3 if party==61320
gen autlibusr3=autlibus3 if party==61620

preserve
collapse (mean) ecoposusd ecoposusr autlibusd autlibusr ecoposusd2 ecoposusr2 autlibusd2 autlibusr2 ecoposusd3 ecoposusr3 autlibusd3 autlibusr3, by(year)
gen autlibus=(autlibusr)-autlibusd
gen ecoposus=(ecoposusr)-ecoposusd
gen autlibus2=(autlibusr2)-autlibusd2
gen ecoposus2=(ecoposusr2)-ecoposusd2
gen autlibus3=(autlibusr3)-autlibusd3
gen ecoposus3=(ecoposusr3)-ecoposusd3
twoway line ecoposus autlibus3 year, scheme(s1mono) title(USA) xtitle("") xlab(1956 1960 1964 1968 1972 1976 1980 1984 1988 1992 1996 2000 2004 2008 2012 2016 2020, angle(45)) lpattern(dash solid) lcolor(black black) legend(order(1 "Economic polarization" 2 "Social polarization")) // saving(manifestus, replace)
save "C:\Users\au22016\Dept of Pol Science Dropbox\Rune Stubager\02_ClassIDscandi\Data\ANES\USmanifest.dta", replace // replace with your directory
restore

*Figure A6.1
grc1leg manifestdk.gph manifestno.gph manifestuk.gph manifestus.gph, imargin(0 0 0 0)



